import os

curr_dir = os.path.abspath(os.path.dirname(__file__))
basedir = os.path.abspath(os.path.dirname(curr_dir))


class Setting:  # 父类可以被下边的类继承到AUTHOR参数
    AUTHOR = 'xtoad'
    # 服务器地址
    HOST = '127.0.0.1'
    # 服务器端口
    PORT = '8081'
    # 启用调试模式开关
    DEBUG = False
    # 热加载开关
    USE_RELOADER = True
    # 关闭ascii转码
    RESTFUL_JSON = dict(ensure_ascii=False)
    # 指定Content-Type
    JSONIFY_MIMETYPE = 'application/json;charset=utf-8'

    # SECRET_KEY
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'xtoad20191022'
    # TOKEN_KEY
    TOKEN_KEY = 'x-token'
    # token 过期时间 s
    TOKEN_EXPIRES = 10
    # 日志相关
    # FATAL > ERROR > WARN > INFO > DEBUG > NOTSET
    LOG_LEVEL = 'DEBUG'
    LOG_FORMATTER = '%(asctime)s %(levelname)s %(funcName)s %(pathname)s %(lineno)s %(message)s'
    LOG_PATH = os.path.join(basedir, 'logs')
    LOG_PATH_ERROR = os.path.join(LOG_PATH, 'error.log')
    LOG_PATH_INFO = os.path.join(LOG_PATH, 'info.log')
    LOG_FILE_MAX_BYTES = 100 * 1024 * 1024
    # 轮转数量是 10 个
    LOG_FILE_BACKUP_COUNT = 10

